package org.idea.qiyu.framework.gateway.starter;

import org.idea.qiyu.framework.gateway.starter.registry.ApplicationRegistry;
import org.idea.qiyu.framework.gateway.starter.registry.ZookeeperRegistry;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author linhao
 * @Date created in 9:40 上午 2022/4/16
 */
@Configuration
@EnableConfigurationProperties(GatewayProperties.class)
public class GatewayAutoConfiguration {

    @Bean
    public ApplicationRegistry applicationRegistry(){
        return new ZookeeperRegistry();
    }

    @Bean
    @ConditionalOnBean(ApplicationRegistry.class)
    public GatewayApplicationRegistryHandler gatewayApplicationRegistryHandler(){
        return new GatewayApplicationRegistryHandler();
    }
}
